package com.yunyi.ne.controller;


import com.yunyi.ne.netty.WebSocketService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/netty")
public class NettyLinkController {
    @Autowired
    private WebSocketService webSocketService;


    @GetMapping("/getNetty")
    public void getNetty(@RequestParam("port") String port,
                         @RequestParam("ip") String ip,
                         @RequestParam("msg") String msg) throws Exception {
        String temp = "ws://%s:%s";
        String format = String.format(temp, ip, port);
        webSocketService.sendMessageToServers(msg, format);
    }


}
